package com.songtech.province.controller;

import com.songtech.base.common.BaseConstant;
import com.songtech.base.common.JsonResult;
import com.songtech.province.bean.Province;
import com.songtech.province.service.ProvinceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @Author: yangzhicheng
 * @Date: 2018/6/21 21:21
 */
@RestController
@RequestMapping("/province")
public class ProvinceController {
    private final Logger logger = LoggerFactory.getLogger(ProvinceController.class);

    @Autowired
    private ProvinceService provinceService;

    /**
     * 查询省份信息
     * @return
     */
    @RequestMapping(value = "/selectProvince",method = RequestMethod.GET)
    public JsonResult setlectProvince(){
        List<Province> list=null;
        try {
            list=provinceService.setlectProvince();
        } catch (Exception e) {
            logger.error("查询省份信息异常:"+e.getMessage(),e);
            return new JsonResult(list, BaseConstant.FAIL_CODE, BaseConstant.FAIL);
        }
        return new JsonResult(list, BaseConstant.SUCCESS_CODE, BaseConstant.SUCCESS);

    }
}
